<?php defined('InShopNC') or exit('Access Invalid!');?>
<script src="<?php echo RESOURCE_SITE_URL;?>/js/common_select.js"></script> 
<script src="<?php echo RESOURCE_SITE_URL;?>/js/area_array.js"></script>
<script src="<?php echo RESOURCE_SITE_URL;?>/js/input_max.js"></script>
<style>
    /* input放大by input_max.js */
    .parentCls { display: inline-block; *display: inline/*IE7*/; *zoom: 1;}
    .js-max-input { font-size: 20px; color: #F40; background: #FFFAE5; white-space: nowrap; padding: 7px; border: solid 1px #FFD2B2;}

</style>
<div class="ncc-main">
  <div class="ncc-title">
    <h3>购买兑换码</h3>
    <h5>设置购买数量</h5>
  </div>
    <form method="post" id="order_form" name="order_form" action="index.php">
    <input type="hidden" name="goods_id" value="<?php echo $output['goods_id'];?>">
    <input type="hidden" name="buyer_phone1" id="buyer_tel" value="">
    <?php include template('buy/buy_virtual_goods_list');?>
    <?php include template('buy/buy_virtual_amount');?>
    <input value="buy_virtual" type="hidden" name="act">
    <input value="buy_step2" type="hidden" name="op">
    <!-- offline/online -->
    <input value="online" name="pay_name" id="pay_name" type="hidden">
    <!-- 默认使用的发票 -->
<!--    <input value="--><?php //echo $output['inv_info']['inv_id'];?><!--" name="invoice_id" id="invoice_id" type="hidden">-->
    <input value="<?php echo getReferer();?>" name="ref_url" type="hidden">
    </form>
</div>
<script type="text/javascript">
//计算部运费和每个店铺小计
/*function calcOrder() {
    var allTotal = 0;
    $('em[nc_type="eachStoreTotal"]').each(function(){
        store_id = $(this).attr('store_id');
        var eachTotal = 0;
        if ($('#eachStoreGoodsTotal_'+store_id).length > 0) {
        	eachTotal += parseFloat($('#eachStoreGoodsTotal_'+store_id).html());
	    }
        $(this).html(number_format(eachTotal,2));
        allTotal += eachTotal;
    });
    $('#orderTotal').html(number_format(allTotal,2));
}*/
$(function(){
    $.ajaxSetup({
        async : false
    });
    calc_price();
    new TextMagnifier({
        inputElem: '.inputElem',
        align: 'top'
    });


});
function disableOtherEdit(showText){
	$('a[nc_type="buy_edit"]').each(function(){
	    if ($(this).css('display') != 'none'){
			$(this).after('<font color="#B0B0B0">' + showText + '</font>');
		    $(this).hide();		    
	    }
	});
	disableSubmitOrder();
}
function ableOtherEdit(){
	$('a[nc_type="buy_edit"]').show().next('font').remove();
	ableSubmitOrder();
	
}
function ableSubmitOrder(){
	$('#submitOrder').on('click',function(){submitNext()}).css('cursor','').addClass('ncc-btn-acidblue');
}
function disableSubmitOrder(){
	$('#submitOrder').unbind('click').css('cursor','not-allowed').removeClass('ncc-btn-acidblue');
}
/**
 * 更改数量
 */
function change_quantity(input){
	var value = Number($(input).val());
	var maxvalue = Number($(input).attr('maxvalue'));
	if (value > maxvalue) {
		$(input).val($(input).attr('maxvalue'));
	}else if (value <= 0) {
		$(input).val(1);
	}

	calc_price();
}

/**
 * 减少商品数量
 */
function decrease_quantity(){
	var input = $('#quantity');
    var orig = Number(input.val());
    if(orig > 1){
    	input.val(orig - 1);
    	input.keyup();
    }
    calc_price();
}

/**
 * 增加商品数量
 */
function add_quantity(){
	var input = $('#quantity');
    var orig = Number(input.val());
    input.val(orig + 1);
    input.keyup();
    calc_price();
}

/**
 * 价格计算
 */
function calc_price() {
	var input = $('#quantity');
	var total = $(input).val()*$(input).attr('price');
	$('#item_subtotal').html(number_format(total,2));
	$('#cartTotal').html(number_format(total,2));
}
</script>